package br.com.cinesystem.persistence;
import java.sql.*;

public class Dao {

    protected Connection con;
    protected ResultSet rs;
    protected PreparedStatement stmt;


    public void abrirConexao() throws Exception{
        String driver = "com.mysql.jdbc.Driver";
        String url = "jdbc:mysql://localhost:3306/cinema?useUnicode=true&characterEncoding=Cp1252";
        String user = "root";
        //String url = "jdbc:mysql://174.133.56.122:3306/cinema?useUnicode=true&characterEncoding=Cp1252";
        //String user = "usuario";
        String pass = "coti";

        Class.forName(driver);
        con = DriverManager.getConnection(url, user, pass);

    }

    public void fecharConexao(){
        try {
            if (con!=null) {
                con.close();
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }

    }

    public static Connection getReportConection() throws Exception{
        String driver = "com.mysql.jdbc.Driver";

        Class.forName(driver);
        
        return DriverManager.getConnection("jdbc:mysql://localhost:3306/cinema?useUnicode=true&characterEncoding=Cp1252",
                "root","coti");
    }
}

